package game.gui;

/**
 * This class represents a window allowing a user to choose one of four colors.
 * It is called by the controller when a wild card is played.
 * @author Kristen
 */

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

import game.driver.Controller;
import game.utils.Util;

public class ColorSelectGUI extends JFrame implements ActionListener{
	
	private static final long serialVersionUID = -7317934722379465455L;

	Controller controller;
	
	JButton greenButton;
	JButton redButton;
	JButton blueButton;
	JButton yellowButton;
	
	/**
	 * This is the constructor. It creates the window
	 * @param c, the controller.
	 */
	public ColorSelectGUI(Controller c){
		super(Util.SELECT_COLOR);
		controller=c;
		setSize(300, 300);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setLayout(new GridLayout(2,2));
		addColors();
		setVisible(true);
	}
	
	/**
	 * This method adds the four buttons to the window.
	 * When a button is chosen, it calls a method in controller to
	 * continue the game.
	 */
	private void addColors(){
		greenButton=new JButton(new ImageIcon(".\\images\\greenHand.png"));
		redButton=new JButton(new ImageIcon(".\\images\\redHand.png"));
		blueButton=new JButton(new ImageIcon(".\\images\\blueHand.png"));
		yellowButton=new JButton(new ImageIcon(".\\images\\yellowHand.png"));
		
		add(greenButton);
		add(redButton);
		add(blueButton);
		add(yellowButton);
		
		greenButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				controller.setWildColor(Color.GREEN);
				dispose();
			}
		});
		redButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				controller.setWildColor(Color.RED);
				dispose();
			}
		});
		blueButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				controller.setWildColor(Color.BLUE);
				dispose();
			}
		});
		yellowButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				controller.setWildColor(Color.YELLOW);
				dispose();
			}
		});
	}

	public void actionPerformed(ActionEvent e) {
	
	}

}
